/* =============================================================================
 * BeeWorks MoneyPile - Domain Model
 *
 * 
 * =============================================================================
 *
 * Developers: Jurgen Lust
 *
 * 
 * (C) Copyright 2009, BeeWorks BVBA.
 *
 */

package be.beeworks.moneypile.model;

import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

import java.io.Serializable;

import java.util.UUID;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


/**
 * A Contact is a customer or a supplier
 *
 * @author jlust
 * @author $LastChangedBy: Jurgen.Lust $
 *
 * @version $LastChangedRevision: 15 $
 */
@Entity
@Table(name = "CONTACTS")
@Indexed
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Contact
        implements Serializable {
    //~ Static fields/initializers ---------------------------------------------

    private static final long serialVersionUID = -6535026789555164639L;

    //~ Instance fields --------------------------------------------------------

    @Version
    @XmlTransient
    private Long version;
    @NotNull
    @Size(min = 1, max = 100)
    @Field(index = Index.TOKENIZED, store = Store.NO)
    private String address;
    @NotNull
    @Field(index = Index.TOKENIZED, store = Store.NO)
    @Size(min = 1, max = 40)
    private String city;
    @Field(index = Index.TOKENIZED, store = Store.NO)
    @Size(min = 1, max = 60)
    private String contactName;
    @NotNull
    @Size(min = 1, max = 40)
    private String country;
    @Size(max = 100)
    private String email;
    @Size(max = 20)
    private String fax;
    @Size(max = 20)
    private String gsm;
    @Id
    @Size(min = 32, max = 32)
    @XmlID
    @DocumentId
    private String id;
    @NotNull
    @Size(min = 1, max = 60)
    @Field(index = Index.TOKENIZED, store = Store.NO)
    private String name;
    @Size(max = 20)
    private String telephone;
    @Size(max = 20)
    private String vatNumber;
    @NotNull
    @Size(min = 1, max = 10)
    private String zip;

    //~ Constructors -----------------------------------------------------------

    public Contact() {
        super();
        this.id = UUID.randomUUID().toString().replaceAll("-", "");
    }

    //~ Methods ----------------------------------------------------------------

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getVersion() {
        return version;
    }

    public String getName() {
        return name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(final String contactName) {
        this.contactName = contactName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(final String address) {
        this.address = address;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(final String zip) {
        this.zip = zip;
    }

    public String getCity() {
        return city;
    }

    public void setCity(final String city) {
        this.city = city;
    }

    public String getVatNumber() {
        return vatNumber;
    }

    public void setVatNumber(final String vatNumber) {
        this.vatNumber = vatNumber;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(final String telephone) {
        this.telephone = telephone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(final String fax) {
        this.fax = fax;
    }

    public String getGsm() {
        return gsm;
    }

    public void setGsm(final String gsm) {
        this.gsm = gsm;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(final String email) {
        this.email = email;
    }
}
